<?php
class Training_TranslateController extends Zendvn_Controller_Action{
	
	public function init(){
		parent::init();
		echo '<br>' . $this->_locale = 'vi_VN';
	}
	
	public function index6Action(){
		//locale: English - USA - Vietname
		$lang = $this->_request->getParam('lang');
		//$arrCountry = array('VN'=>"Vietnamese", "US"=>"USA",'GB'=>'English','DE'=>"German");
		$this->view->arrCountry = $arrCountry;
		$locale = new Zend_Locale();
// 		$locale->getTr
		//$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index5Action(){
		
		//$this->_helper->viewRenderer->setNoRender();
	}
	
	
	public function index4Action(){
		$dirLang = 'de_DE';
		$fileLang = LANG_PATH . '/' . $dirLang . '/lang.tmx';
		echo $fileLang;
		$options = array(
							'adapter'=>'Tmx',
							'content' => $fileLang,
							'locale' => 'de',
				
						);
		$translate = new Zend_Translate($options);
		//$translate->setLocale('vi');
		echo '<br>' . $translate->_('The chicken');
		echo '<br>';
		printf($translate->_("Today is %s the and I'm using %s language"),date("d-M-Y"),'Vietnam');
		
	
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index3Action(){
		$fileLang = LANG_PATH . '/lang.tmx';
		
		$options = array(
							'adapter'=>'Tmx',
							'content' => $fileLang,
							'locale' => 'en',
				
						);
		$translate = new Zend_Translate($options);
		$translate->setLocale('vi');
		echo '<br>' . $translate->_('The chicken');
		echo '<br>';
		printf($translate->_("Today is %s the and I'm using %s language"),date("d-M-Y"),'Vietnam');
		
		echo '<pre>';
		print_r($translate);
		echo '</pre>';
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index2Action(){
		
		$english = array(
			 'The chicken'=> 'The chicken 1',
			 'The children'=> 'The children',
			 'The teacher'=> 'The teacher',
			 'date'=> "Today is the %1\$s and I'm using %2\$s language"
			 );
			 
		$vietnam = array(
			 'The chicken'=> 'Con ga',
			 'The children'=> 'nhung dua tre',
			 'The teacher'=> 'Giao vien',
			 'date'=> "Hom nay la ngay %1\$s va ban dang su dung ngon ngu %2\$s"
			 );
		//Them vao ngon ngu tieng Anh	 
		$options = array('adapter'=>'Array','content'=>$english,'locale'=>'en');		
		$translate = new Zend_Translate($options);
		
		//Them vao ngon ngu tieng Viet
		$options = array('adapter'=>'Array','content'=>$vietnam,'locale'=>'vi');
		$translate->addTranslation($options);
		
		$translate->setLocale('en');
		
		//Dua doi tuong Translate ra ngoai View
		Zend_Registry::set('Zend_Translate',$translate);
	}
	
	public function indexAction(){
		/*$english = array(
			 'chicken'=> 'The chicken',
			 'children'=> 'The children',
			 'teacher'=> 'The teacher',
			 'date'=> "Today is the %1\$s and I'm using %2\$s language"
			 );*/
		$english = array(
			 'The chicken'=> 'The chicken 1',
			 'The children'=> 'The children',
			 'The teacher'=> 'The teacher',
			 'date'=> "Today is the %1\$s and I'm using %2\$s language"
			 );
			 
		$vietnam = array(
			 'The chicken'=> 'Con ga',
			 'The children'=> 'nhung dua tre',
			 'The teacher'=> 'Giao vien',
			 'date'=> "Hom nay la ngay %1\$s va ban dang su dung ngon ngu %2\$s"
			 );
		//Them vao ngon ngu tieng Anh	 
		$options = array('adapter'=>'Array','content'=>$english,'locale'=>'en');		
		$translate = new Zend_Translate($options);
		
		//Them vao ngon ngu tieng Viet
		$options = array('adapter'=>'Array','content'=>$vietnam,'locale'=>'vi');
		$translate->addTranslation($options);
		
		/*$translate->setLocale('en');		
		echo '<br>' . $translate->_('The chicken');
		
		$translate->setLocale('vi');		
		echo '<br>' . $translate->_('The chicken');*/
		printf('This is a %s test %d','acb123',12);
		echo '<br>' . $translate->_('date');
		echo '<br>';
		printf($translate->_('date'),date("d-m-Y"),'Vietnam');
		
		Zend_Registry::set('Zend_Translate',$translate);
		
	
		$this->_helper->viewRenderer->setNoRender();
	}
	
}